package com.summo.sbmy.service.impl;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import com.summo.sbmy.cache.sys.SysConfigCacheManager;
import com.summo.sbmy.common.base.RedisConnectException;
import com.summo.sbmy.common.model.dto.SkylineWebcamsDTO;
import com.summo.sbmy.dao.entity.SbmySysConfigDO;
import com.summo.sbmy.dao.repository.SbmySysConfigRepository;
import com.summo.sbmy.service.SbmySysConfigService;
import com.summo.sbmy.service.convert.SbmySysConfigConvert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SbmySysConfigServiceImpl implements SbmySysConfigService {
    @Autowired
    private SbmySysConfigRepository sbmySysConfigRepository;

    @Override
    public List<SkylineWebcamsDTO> querySkylineWebcams() {
        List<SbmySysConfigDO> skylineWebcams = SysConfigCacheManager.getConfigByGroupCode("SkylineWebcams");
        //随机排列顺序
        Collections.shuffle(skylineWebcams);
        return skylineWebcams.subList(0, 3).stream().map(SbmySysConfigConvert::toSkylineWebcamsDTOWhenQuery).collect(
            Collectors.toList());
    }
}
